<?php

namespace Trawind\Remotes\Repositories\Report\Product;

use Trawind\Remotes\BaseRepository;
use Trawind\Basics\Enums\ServiceDomain;
use Trawind\Remotes\Contracts\Repositories\Report\Product\PublicityDetailsRepository;

/**
 * Class PublicityDetailsRepositoryEloquent.
 *
 * @package namespace Trawind\Remotes\Repositories\Report\Product;
 */
class PublicityDetailsRepositoryEloquent extends BaseRepository implements PublicityDetailsRepository
{

    public $baseRoute='/product/publicity-details';

    /**
     * PublicityDetailsRepositoryEloquent constructor.
     */
    public function __construct()
    {
        $this->domain = ServiceDomain::REPORT_DOMAIN();
    }


    /**
     * Retrieve all data of repository
     *
     * @param array $columns
     *
     * @return mixed
     */
    public function all($columns = ['*'])
    {
        return $this->setUrl($this->baseRoute)->result();
    }



    /**
     * Find data by id
     *
     * @param       $id
     * @param array $columns
     *
     * @return mixed
     */
    public function find($id, $columns = ['*'])
    {
        return $this->setUrl($this->baseRoute.'/'.$id)->result();
    }




    /**
     * Save a new entity in repository
     *
     * @param array $attributes
     *
     * @return mixed
     */
    public function create(array $attributes)
    {
        return $this->setUrl($this->baseRoute)
            ->setClientOptions(['form_params' => $attributes])
            ->result('POST');
    }



    /**
     * Update a entity in repository by id
     *
     * @param array $attributes
     * @param       $id
     *
     * @return mixed
     */
    public function update(array $attributes, $id)
    {
        return $this->setUrl($this->baseRoute.'/'.$id)
            ->setClientOptions(['form_params' => $attributes])
            ->result('PUT');
    }
}
